import React from 'react';
const KEY_CODE=13
export default class TodoHeader extends React.Component{
    handleKeyDown=(event)=>{
        if(event.keyCode===KEY_CODE){
            let title=event.target.value
            this.props.addTodo({title})
            event.target.value=''
        }
    }
    render(){
        return (
            <div>
             <input type="text" autoFocus className="form-control" id="name" placeholder="请输入你想做的事" onKeyDown={this.handleKeyDown}/>
            </div>
        )
    }
}